package com.smarttoolfactory.tutorial1_1basics.chapter6_graphics

import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Slider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.Group
import androidx.compose.ui.graphics.vector.PathNode
import androidx.compose.ui.graphics.vector.PathParser
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.smarttoolfactory.tutorial1_1basics.ui.Blue400
import com.smarttoolfactory.tutorial1_1basics.ui.Orange400
import com.smarttoolfactory.tutorial1_1basics.ui.components.TutorialHeader

@Preview
@Composable
fun Tutorial6_27Screen() {
    TutorialContent()
}

@Composable
private fun TutorialContent() {
    Column(
        modifier = Modifier
            .padding(16.dp)
            .verticalScroll(rememberScrollState())
    ) {
        TutorialHeader(text = "Custom VectorPainter")
        CustomVectorDrawableSample()

    }
}

@Preview
@Composable
private fun CustomVectorDrawableSample() {

    var index by remember {
        mutableStateOf(0f)
    }

    Column {
        Netherlands(
            modifier = Modifier
                .background(Blue400)
                .fillMaxWidth()
                .aspectRatio(1f),
            selectedIndex = index.toInt()
        )

        Slider(
            value = index,
            onValueChange = {
                index = it
            },
            valueRange = 0f..3f,
            steps = 2

        )
    }
}

@Composable
fun Netherlands(modifier: Modifier = Modifier, selectedIndex: Int) {

    val vectorPainter = rememberVectorPainter(
        defaultWidth = 200.dp,
        defaultHeight = 236.dp,
        viewportHeight = 236f,
        viewportWidth = 200f,
        autoMirror = false
    ) { _, _ ->
        val duration = 3000
        val transition = rememberInfiniteTransition(label = "transition")
        val scale by transition.animateFloat(
            initialValue = 1.0f,
            targetValue = 1.4f,
            animationSpec = infiniteRepeatable(
                tween(duration, easing = EaseInOut),
                repeatMode = RepeatMode.Reverse
            ), label = "scaleTransition"
        )

        var index = 0

        var selectedProvince: String? = null
        for (entry in Netherlands.PathNodeMap) {
            val (province, paths) = entry

            val pathList = Netherlands.PathMap[province]
            val pathForSize = Path()
            pathList?.forEach {
                pathForSize.addPath(it)
            }

            val center = pathForSize.getBounds().center

            Group(
                name = province,
                scaleX = 1.0f,
                scaleY = 1.0f,
                pivotX = center.x,
                pivotY = center.y
            ) {
                for (path in paths) {
                    androidx.compose.ui.graphics.vector.Path(
                        stroke = SolidColor(Blue400),
                        pathData = path,
                        fill = SolidColor(Color.Black)
                    )
                }
            }

            if (selectedIndex == index) {
                selectedProvince = province
            }

            index++
        }

        // This is drawn above other path nodes
        selectedProvince?.let { province ->
            Netherlands.PathNodeMap[province]?.let { paths: List<List<PathNode>> ->

                println("SelectedIndex: $selectedIndex, selectedProvince: $selectedProvince")

                val pathList = Netherlands.PathMap[province]
                val pathForSize = Path()
                pathList?.forEach {
                    pathForSize.addPath(it)
                }

                val center = pathForSize.getBounds().center

                Group(
                    name = province,
                    scaleX = scale,
                    scaleY = scale,
                    pivotX = center.x,
                    pivotY = center.y
                ) {
                    for (path in paths) {
                        androidx.compose.ui.graphics.vector.Path(
                            stroke = SolidColor(Color.White),
                            pathData = path,
                            fill = SolidColor(Orange400),
                        )
                    }
                }
            }
        }
    }

    Image(
        modifier = modifier,
        painter = vectorPainter,
        contentDescription = null
    )
}

typealias Province = String

internal object Netherlands {
    val PathParserMap = mapOf<Province, List<PathParser>>(
        "Overijssel" to listOf(
            PathParser().parsePathString(
                "m144.01 59.386-1.162 0.77493-0.77463 0.77492h-1.162-0.38732l0.38732 0.77492v0.38746h-0.38732l-0.38731 0.38746-0.77463 0.38746v-0.77492l-1.162 0.38746-0.38732 0.38746v-0.38746h-0.38731l-0.38732-0.38746-0.38731-0.77492v-0.77492l-0.77464 0.38746v0.38746l-0.77463-0.38746v0.38746h-0.77463l-0.38732 0.38746v0.38746l-0.38731 0.38746v0.38746l-0.38732 0.38747h-0.38731v0.38746h-0.38732l-0.38732 0.38746h-0.38731-0.38732-0.38731l-0.38732-0.38746h-0.38732-0.38731v-0.38746h-0.38732-0.38731v-0.38747h-0.38732l-0.77463 0.77493 0.38731 0.77492 0.77464 0.77492v0.38746h0.77463 0.77463l0.38732 0.38746 1.1619 0.38747 0.38732 0.77492 0.38732 0.38746h0.38731l0.77463 0.77492 0.38732 1.1624 0.77463 1.5498v0.38746h0.38732l0.38731 0.38746v0.38746l0.38732 0.38747v0.38746 0.38746l-0.77463 0.38746-0.77463 0.77492v0.38746 0.38746h0.38731v-0.38746l0.77463 0.38746h0.38732l0.77463 0.38747 0.38732 0.38746 0.38731 0.38746h0.77463l0.38732 0.77492-0.38732 0.38746-1.1619 0.77492h-0.38732l-1.162 0.38747v0.38746l-0.77463 0.38746h-0.38731l-0.77464 0.38746-0.77463-0.77492-3.0985 0.77492-0.38731 0.38746v0.77492 0.38746 0.38747l0.38731 0.38746v0.38746l-1.5493-0.38746 0.38732 0.38746h0.38731 0.38732v0.38746l0.38731 0.38746v0.38746 0.38746l0.38732 0.38746 0.38732 0.38747v0.38746 0.38746l0.38731 0.38746v0.77492 0.77492l0.77463-0.38746 0.38732 0.38746 0.77463 1.1624 0.38732 0.77492 0.77463 1.1624v0.77493l0.77463-0.38747 0.77463-0.77492v0.38746l0.38732 0.38746 2.3239-2.3248h0.38732 0.38732l0.38731-0.38746 0.38732 0.38746h0.38731l0.77464 0.77492v0.38746 0.38746l0.38731 0.38746 1.162 0.38746 0.38732 0.38747v0.38746l0.38731 1.1624v0.77492l0.38732 0.38746 0.38731 0.38747v0.77492l-0.38731 0.38746v0.38746 0.77492l0.38731 0.38746h0.38732v0.38747 0.38746 0.77492h-0.38732v0.38746h-0.38731l-0.77463 0.38746h-0.77464v0.38746h-0.38731v0.38746l0.38731 0.38747h0.38732l0.38732 0.38746h-0.38732l-0.38732 0.38746h-0.38731v0.77492 0.77492 0.77493h-0.38732v0.38746h0.38732 0.38731v0.38746 1.1624h0.38732 0.38732 0.38731v0.38746 0.38746h0.38732v1.1624l0.77463 0.77492v0.38746 0.38746 0.38746l0.38732 0.38747h0.38731 0.38732 0.38731v0.38746h-0.38731l-0.38732 0.38746v0.38746l0.38732 0.77492h0.38731 0.38732v-0.38746l0.77463-0.38746h0.38732v0.38746h0.77463 0.38731l0.38732 0.38746v-0.38746h0.38732 0.38731 0.38732 0.77463 0.38732l0.38731 0.38746 0.38732-0.38746h0.38731 0.38732 0.38732v0.38746h1.1619v-0.38746h0.77464v-0.77492h0.38731l0.38732-0.38746h0.77463 0.38732l0.38731-0.38746v0.38746h0.38732 0.38731 0.77464 0.38731v0.38746 0.38746l0.38732 0.77492 1.1619 0.77492v0.77493h0.38732v0.38746h0.77463v0.77492l0.38732 0.38746v0.38746h0.38731l0.38732 0.38746 0.77463-0.38746h0.38732l1.9366 0.38746 1.5493-0.38746h0.38732l0.77463 0.38746-0.38732 0.38746 0.77464 0.77493v-0.38746l0.38731-0.38747 0.38732-0.38746 0.38731 0.38746v0.38747l0.38732-0.77493h0.38731l1.162 0.77493v0.38746 0.38746 1.1624l-0.77463 1.1624h0.77463 0.38732l1.5493 0.77492h0.38732 2.3239 3.0985 1.162l0.38731-0.38746 0.77464-0.77493v-0.38746l0.38731-1.9373h0.38732v-0.38746l1.162-0.77493v-0.38746l1.1619-0.38746h1.162l0.38732-0.77492v-0.38746l0.38731-0.38746v-0.38747l0.38732-0.38746v-0.38746-0.38746-0.38746l0.38732-0.38746 0.77463-0.38746 0.38731 0.38746h0.38732 0.38732 0.77463l1.1619-0.77492v-0.38746l-1.1619-1.5498-0.38732-0.38746v-0.77492h-0.38731v-0.38746-0.38747-0.38746-0.38746l0.38731-1.1624v-0.38746h0.38732v-0.38746h0.38731v-0.38747-0.38746l0.38732-0.77492v-0.38746l0.77463-1.1624v-1.9373l-0.77463-1.5498v-0.38746-0.38746h-0.38732-0.38731-0.38732l-0.38731-0.77492-0.38732-0.77492-0.77463-0.77493v-0.38746l-0.38732-0.77492v-0.77492l-0.38731-0.77492v-0.38747h-0.38732-0.38732l-0.38731 0.77493-0.38732 1.1624-0.77463 0.38746v0.38746h-0.38732l-1.9366-0.38746-0.77463-0.38746-1.162-0.38746h-0.77463l0.38732-0.77492h-0.77463-1.162-2.3239-0.77463l-0.38731-0.38746-1.5493-0.77493-0.38731-0.38746-0.77464-0.38746 0.38732-3.0997-0.77463-1.1624-0.77463-1.5498h0.38731l0.77463 0.38746h0.77464l0.38731-1.1624h0.77463l0.77464 0.38746 0.38731-0.38746-2.3239-1.9373v-0.77492l0.38731-1.5498v-0.38746l-0.38731-0.38747-0.38732-0.38746h-0.38732v-0.38746-0.38746-0.38746l0.38732-0.38746-0.38732-0.38746h-0.77463l-3.8732-1.9373v0.38746h-0.38731l-1.162 0.38746h-1.5493l-1.9366 1.9373 0.38731 2.3248v0.38746h-0.38731l-0.38732-0.38746h-0.38732-0.77463l-0.77463-0.77493v0.38747l-0.77463 0.77492-0.38732-0.38746h-0.38731v-0.38746-0.38747h-0.38732l-0.38731 0.38747v0.38746h-0.38732v-0.38746h-0.38732v0.38746h-0.38731-0.38732v0.38746h-0.38731l-0.38732-0.38746v-0.77493l-0.38732-0.38746v-0.38746h-0.38731v-0.38746-0.38746h-0.38732l-0.38731-0.38746h-0.38732l-0.38732-0.38746v-0.38746h-0.38731v-0.38747h0.38731v-0.38746h-0.38731-0.38732l-0.38731 0.38746h-0.38732-0.38732-0.38731v-0.38746h-0.38732v0.38746h-0.38731-0.38732v-0.38746h-0.38732l-0.38731-0.38746v-0.38746h-0.38732-0.38731-0.38732v-0.38746h-0.38732-0.38731-0.38732l-0.38731 0.38746v0.38746l-0.38732-0.38746v-0.38746l-0.38731 0.38746 0.38731 0.38746-1.162-0.38746 0.38732-0.38746v-0.38746l-0.77463-0.38746v-0.38746l-0.77463-1.1624v-0.38746-0.38746l-0.38732-0.77492-0.38732-0.77493-0.38731-0.77492v-0.38746h0.38731l0.38732-0.38746 1.162-0.38746 0.38731-0.38746h0.38732v-0.38746l0.77463-0.77493 0.38732-0.38746 0.38731-0.77492h-0.38731l-0.38732-0.77492-3.0985-3.0997v-0.38746l-0.38731-0.77493zm2.7112 52.695v0.38746 0.38746l0.38732-0.38746-0.38732-0.38746z"
            )
        ),
        "Gelderland" to listOf(
            PathParser().parsePathString(
                "m132.01 87.283-0.77463 0.38746v0.38746l-0.38731 1.1624-0.38732 0.77492v0.38746 0.38746l-0.38732 0.77493v0.38746 0.38746l-0.38731-0.38746v0.77492h-0.38732v-0.38746-0.38746l-0.38731 0.77492v0.38746h0.38731v0.38746h-0.38731l0.38731 0.38746-0.77463 0.77493-1.9366 1.9373-0.77463 0.38746v0.38746h-0.38732l-0.38731 0.38747h-0.38732l-0.38731 0.38746v0.38746h-0.38732v0.38746h-0.38732-0.38731l-0.77463 0.38746-0.38732 0.38746h-0.38732l-0.38731 0.38746-0.77463 0.38746h-0.38732l-0.77463 0.77493v0.38746h-0.38732-0.38731v0.38746 0.38746h-0.38732v0.38746h-0.38732v0.38746h-0.38731v0.38746l-0.77463 0.38747-0.77463 0.77492v0.38746l-0.38732 0.77492v0.77492l-0.38732 0.77493v0.38746l-0.38731 0.77492-0.38732 0.38746h-1.5493-0.38732l-0.77463 0.77492-0.38732-0.38746-0.38731 0.38746-1.162 0.38747h-0.77463l-0.38732 0.38746h-0.77463l-0.38732 1.9373v0.38746l0.77464 0.38746v-0.38746l1.5493 1.1624v0.38746 0.38746 0.38746 0.38746 1.1624l0.38732 0.38746h1.9366v0.38746h-0.38732l0.38732 0.38746v0.38746 0.38746h0.38731 0.38732v0.77492h0.77463v0.38747 0.38746h-0.77463v0.38746 0.38746h0.38731v0.38746h-0.38731-0.38732v0.38746l-0.38731 0.38746v0.77493 0.38746l-0.77464 0.77492h-0.38731v0.38746l0.38731 0.38746 0.77464 0.38746h0.38731 0.38732l0.38731-0.38746 0.38732-0.38746h0.38732l0.38731-0.38746v-0.38746h0.38732v-0.38746-0.38746l-0.38732-0.38747 1.162-0.38746 0.38732 0.77493v0.38746 0.38746 0.38746l0.38731 0.38746-0.38731 0.38746v0.38746 1.9373h0.77463v0.38746h-0.38732l1.162 0.77492v1.1624 0.38746 0.38746 0.38746l0.77463 0.77492h0.38732v0.38746l0.38731 0.77493v0.38746l0.38732 0.38746-0.38732 0.38746 0.38732 0.38746v0.38746 0.38746l-0.38732 0.38747-0.77463 0.38746-0.77463-0.38746-1.162-0.38747-0.77463-0.38746-0.38732-0.77492h-0.38731-0.38732l-0.38731-0.38746h-0.38732l-0.77463-0.38746-0.38732-0.38746h-0.38731-0.38732-1.162l-0.38731-0.38746h-0.38732l-0.77463 0.77492h-0.38732l-0.77463 0.38746h-0.38732l-0.38731 0.38746h-0.38732l-0.77463-0.38746-0.38731 0.38746h-0.38732l-0.38732 0.38746v0.38746h-0.38731l-0.38732 0.38746h-0.38731l-0.77464-0.77492h-1.1619-0.38732l-0.77463-0.77492-0.77463-0.38746h-0.38732-0.38732v0.77492l-0.38731 0.38746-0.38732 0.38746h-0.38731-0.38732l-0.38732-0.38746-0.38731-0.38746-0.38732 0.77492-0.38731 1.1624-0.77463 0.77492-0.38732 0.38746h0.38732l-0.38732 0.38746-0.38732 0.77492h-0.38731v0.38747l-0.38732 1.1624-0.38731 0.38746v0.38746h-0.38732-0.77463-0.38732v0.77492l-0.38731 0.38746h-0.38732-0.38732-0.38731v0.38747 0.38746l0.38731 0.38746v0.38746h-0.38731l-0.38732-0.38746-1.162 0.38746-0.38731-0.38746-0.77463 0.38746-0.38732-0.38746v0.38746 0.38746l0.38732 0.38746h-0.38732l0.38732 0.38746h0.38731 0.38732 0.77463l-0.38732 1.5498v0.38746h-0.77463v0.38746 0.38746h0.38732l0.38731 0.38746 0.77464 0.38746 0.38731 0.38747h0.38732v0.38746l0.38731 0.38746v0.38746h0.38732v0.38746h0.38732l0.38731-0.38746 0.38732-0.38746h0.38731l0.77464 0.77492 1.1619 0.38746v0.38746 0.38746 0.38747l0.38732 0.38746-0.77463 0.77492h-0.38732v0.38746l0.38732 0.38746 0.77463-0.38746h0.77463 0.77463 0.38732 0.77463 0.38732 0.38731l0.38732-0.38746 0.38731 0.38746 0.77464 0.38746 0.38731 0.38746 0.77463-0.77492h0.77464l0.77463 0.38746h0.38731v-0.38746l0.77464-0.38746 1.9366-0.77492v-0.38746h0.38731v-0.77493-0.77492l0.38732-0.77492v-0.38746l0.77463-1.1624 0.38731-0.38746 0.38732-0.38746v-0.38746l0.38732-0.38746h0.38731v0.38746l0.38732 0.38746 0.38731 0.38746h0.38732 0.77463 0.77463l0.38732-0.38746 0.38732-0.77492v-0.38746h0.38731 0.38732 0.38731l0.38732 0.38746v0.38746h0.38732 0.38731l0.38732 0.38746h0.38731l0.38732-0.38746v-0.38746l0.38732-0.38746h0.38731 0.77463 0.38732 0.38731l0.77464 0.38746 0.38731 0.38746h0.38732 0.77463l0.38732 0.38746v0.77492l1.1619 1.1624h0.38732 0.38732l0.38731 0.38746h0.38732v0.77492h0.38731l0.38732 0.38746h0.38732 0.38731l0.38732 0.38746 0.38731 0.38746v0.38747l0.38732 0.38746h0.38732 0.38731 0.77463 0.38732l1.162-0.38746h0.38731 1.162 0.77463 0.38732 0.38731v-0.38747-0.38746l-0.38731-0.38746 0.38731-0.38746h0.77464 0.38731l0.38732 0.38746 0.38731 0.38746v0.38746l0.38732 0.38747v0.38746l0.38732 0.38746h0.38731v0.38746l0.38732 0.38746h0.38731l0.38732-0.38746v-0.38746l0.38732-0.38746 0.77463-0.38746h0.38731l0.38732-0.77493v-0.38746h-0.38732v-0.77492h0.38732l-0.38732-0.38746h-0.38731v-0.38746-0.38746-0.38747l-0.77463-0.77492h-0.38732-0.38732v-0.38746l0.38732-0.38746h0.38732l-0.77464-0.38746 0.77464-1.1624h0.38731v0.38747h0.77463 0.38732l0.77463-0.38747h0.38732l0.38731-0.38746 0.38732-0.38746 0.38731 0.38746 0.77464-0.77492h0.38731l-0.38731-0.38746 0.38731-0.38746 0.38732-0.38746 1.162 1.1624h0.38731 0.38732l1.5493 0.38746h1.162l0.38732 0.38746v-0.77492-0.38746-0.38746-0.38746l-0.77464-0.38746h-0.38731v-0.38747-0.38746l-0.38732-0.77492-0.38731-0.38746h-0.77464-0.38731l0.38731-0.38746v-0.38746h0.38732l0.38732 0.38746 1.5493-0.77492 0.38732 0.38746h0.38731l0.38732 0.38746 0.77463 0.38746v0.38746h-0.77463l0.77463 0.77492 0.38731 0.38746 0.77464 0.38747h0.77463v-0.38747h0.77463l0.38732 0.38747h0.38731v-0.38747h0.38732v-0.38746l0.38731 0.38746 1.162 0.38747v0.38746l0.38732 0.77492v0.38746l0.77463-0.38746h0.77463 0.38732l0.38731 0.38746h0.38732l0.38732 0.38746v0.38746 0.38746h0.38731 0.38732 0.38731l0.77464 0.38747h0.38731l-0.38731-0.77493 0.38731 0.38746-0.38731-0.77492v-0.38746l0.38731-0.38746h-0.38731v-0.38746h-0.38732l-0.38732-0.38746v-0.38746-0.77493l0.77464 0.38746h0.38731l0.38732 0.38747h0.38731v0.38746h0.38732 0.38731l0.38732-0.38746 0.38732 0.77492h0.38731l0.38732 0.38746 0.38731-0.38746 1.162-0.38746v-0.38746-0.38747h0.38732l0.38731-0.38746h0.38732 0.38732l0.38731-0.38746v-0.38746h0.38732l0.38731-0.38746v0.38746h0.38732l0.38732-0.38746 0.77463-0.38746 1.9366-0.77492h0.38731 0.38732v-0.38746l0.77463-0.38747 0.77463-0.38746h0.38732l0.38731-0.38746v0.38746h0.38732 0.38732v0.38746l1.1619 1.1624 0.77464-0.38746v-0.38746h0.38731l0.38732-0.38747h0.38731v-0.38746l0.38732-0.38746h0.38732l0.77463-1.1624 0.38731-0.38746v-0.38746-0.38747-1.1624l0.77464-0.38746h0.77463l0.38731-0.77492-0.38731-0.38746v-0.77493-0.38746l-1.162-0.38746h0.38732l-2.3239-1.5498-0.38732-0.38747-0.38731-0.77492-1.9366-0.77492h-1.5493v-0.38746-0.77492-0.38747l0.38732-0.38746v-0.38746-0.38746h1.162l1.5493-0.77492v-0.38746-0.38746-0.38747h0.38732v-0.38746l0.38731-1.5498h-2.3239-0.38732l-1.5493-0.77492h-0.38732-0.77463l0.77463-1.1624v-1.1624-0.38746-0.38746l-1.162-0.77493h-0.38731l-0.38732 0.77493v-0.38747l-0.38731-0.38746-0.38732 0.38746-0.38731 0.38747v0.38746l-0.38732-0.38746-0.38732-0.38747 0.38732-0.38746-0.77463-0.38746h-0.38732l-1.5493 0.38746-1.9366-0.38746h-0.38732l-0.77463 0.38746-0.38732-0.38746h-0.38731v-0.38746l-0.38732-0.38746v-0.77492h-0.77463v-0.38746h-0.38732v-0.77493l-1.1619-0.77492-0.38732-0.77492v-0.38746-0.38746h-0.38731-0.77464-0.38731-0.38732v-0.38746l-0.38731 0.38746h-0.38732-0.77463l-0.38732 0.38746h-0.38731v0.77492h-0.77464v0.38746h-1.1619v-0.38746h-0.38732-0.38732-0.38731l-0.38732 0.38746-0.38731-0.38746h-0.38732-0.77463-0.38732-0.38731-0.38732v0.38746l-0.38732-0.38746h-0.38731-0.77463v-0.38746h-0.38732l-0.77463 0.38746v0.38746l0.38732 0.38746-0.38732 0.38746v-0.38746-0.38746h-0.38732-0.38731l-0.38732-0.77492v-0.38746l0.38732-0.38746h0.38731v-0.38746h-0.38731-0.38732-0.38731l-0.38732-0.38747v-0.38746-0.38746-0.38746l-0.38732-0.38746-0.38731-0.38746v-1.1624h-0.38732v-0.38746-0.38746h-0.38731-0.38732-0.38732v-1.1624-0.38746h-0.38731-0.38732v-0.38746h0.38732v-0.77493-0.77492-0.77492h0.38731l0.38732-0.38746h0.38732l-0.38732-0.38746h-0.38732l-0.38731-0.38747v-0.38746h0.38731v-0.38746h0.77464l0.77463-0.38746h0.38731v-0.38746h0.38732v-0.77492-0.38746-0.38747h-0.38732l-0.38731-0.38746v-0.77492-0.38746l0.38731-0.38746v-0.77492l-0.38731-0.38747-0.38732-0.38746v-0.77492l-0.38731-1.1624v-0.38746l-0.38732-0.38747-1.162-0.38746-0.38731-0.38746v-0.38746-0.38746l-0.77464-0.77492h-0.38731l-0.38732-0.38746-0.38731 0.38746h-0.38732-0.38732l-0.38731 0.38746-1.5493 1.5498-0.38732 0.38746-0.38732-0.38746v-0.38746l-0.38731 0.38746-0.38732 0.38746-0.77463 0.38747v-0.77493l-0.77463-1.1624-0.38732-0.77492-0.77463-1.1624-0.38732-0.38746zm-12.781 13.949-0.77463-0.38746 0.38731 0.38746h0.38732z"
            )
        ),
        "Utrecht" to listOf(
            PathParser().parsePathString(
                "m87.466 105.88v0.38746h-0.38731v0.38746 0.38747l-0.77464-0.38747v0.38747l-0.77463 0.38746v0.38746h-0.38731-0.38732-0.38732l-0.77463-0.38746-0.38731 0.38746v0.38746l0.38731 0.38746-0.38731 0.38746-0.38732 0.38746v0.38746h-0.38731-0.38732v0.38747l-0.38732-0.38747h-0.38731-0.38732l-0.38731 0.38747-0.77464 0.38746v0.38746h-0.38731l-0.38732 0.38746h-0.38731v0.38746h-0.38732l-0.38732 0.38746h-0.38731-0.38732-0.38731v0.38746l0.38731 0.38746v0.77493 0.38746h0.38732v0.38746l0.38731 0.38746h0.38732v0.38746l0.38732 0.38746 0.38731 0.38746h0.77463l0.38732 0.38746 1.5493 1.1624-1.1619 0.38746v1.5498h-0.38732-0.38732-0.77463-0.38731v-0.38746h-0.77464l-0.77463 0.77493h0.38732l-0.38732 0.38746v0.38746h-0.38731-0.38732v0.38746l1.5493 0.77492 0.38732 0.38746h-0.38732v1.1624l0.38732 1.1624v0.38746h0.38732l-0.38732 0.38746h0.77463 1.5493l-0.77464 0.77493h-0.38731l-1.162 0.77492-0.38732 1.1624-0.38731 0.38746h-0.38732v0.38746l-0.38731 0.38747 0.38731 0.77492h0.38732l0.38731-0.38746h0.38732 0.38732 0.38731 0.38732l0.38731 1.1624h-0.38731l-1.5493 0.38746 0.38732 0.38746 0.38732 0.77493 0.38731 0.77492 0.38732 0.38746 0.77463 0.77492v0.38746l0.38732 0.38746v0.77493 0.38746h0.38731 0.77463 0.38732l0.38732-0.38746h0.38731v-0.38746h0.38732l-0.00974-0.41037 0.3 0.3 0.4 1.6 0.2-0.3 0.2-0.2 0.4 1.5 0.4 0.2v0.3l0.4 0.2v1l1.1-0.5v0.6l0.1 0.5v0.7l-0.1 0.3 0.1 0.3 1.4-0.7-0.1 0.9 0.3 0.9-0.05516 0.55959 1.162-0.38746 0.38732 0.38746h0.38731v-0.38746l-0.38731-0.38746v-0.38746-0.38747h0.38731 0.38732 0.38732l0.38731-0.38746v-0.77492h0.38732 0.77463 0.38732v-0.38746l0.38731-0.38746 0.38732-1.1624v-0.38747h0.38731l0.38732-0.77492 0.38732-0.38746h-0.38732l1.162-1.1624 0.38731-1.1624 0.38732-0.77492 0.77463 0.77492h0.38732 0.38731l0.77463-0.77492v-0.77492h0.38732 0.38732l0.77463 0.38746 0.77463 0.77492h0.38732 1.1619l0.77464 0.77492h0.38731l0.38732-0.38746h0.38731v-0.38746l0.38732-0.38746h0.38732l0.38731-0.38746 0.77463 0.38746h0.38732l0.38731-0.38746h0.38732l0.77463-0.38746h0.38732l0.38731-0.38746 0.38732-0.38746h0.38732l0.38731 0.38746h1.162 0.38732 0.38731l0.38732 0.38746 0.77463 0.38746h0.38732l0.38731 0.38746h0.38732 0.38731l0.38732 0.77492 0.77463 0.38746 1.162 0.38747 0.77463 0.38746 0.77463-0.38746 0.38732-0.38747v-0.38746-0.38746l-0.38732-0.38746 0.38732-0.38746-0.38732-0.38746v-0.38746l-0.38731-0.77493v-0.38746h-0.38732l-0.38732-0.38746-0.38731-0.38746v-0.38746-0.38746-0.38746-1.1624l-1.162-0.77492h0.38732v-0.38746h-0.77463v-1.9373-0.38746l0.38731-0.38746-0.38731-0.38746v-0.38746-0.38746-0.38746l-0.38732-0.77493-1.162 0.38746 0.38732 0.38747v0.38746 0.38746h-0.38732v0.38746l-0.38731 0.38746h-0.38732l-0.77463 0.77492h-0.38732-0.38731l-0.77464-0.38746-0.38731-0.38746v-0.38746h0.38731l0.77464-0.77492v-0.38746-0.77493l0.38731-0.38746v-0.38746h0.38732 0.38731v-0.38746h-0.38731v-0.38746-0.38746h0.77463v-0.38746-0.38747h-0.77463v-0.77492h-0.38732-0.38731v-0.38746-0.38746l-0.38732-0.38746h0.38732v-0.38746h-1.9366l-0.38732-0.38746v-1.1624-0.38746-0.38746-0.38746-0.38746l-1.5493-1.1624v0.38746l-0.77464-0.38746v-0.38746l0.38732-1.9373-0.38732-0.38746-0.38731-0.38747-0.38732-0.38746h-0.38731v-0.38746l-0.38732-0.38746h-0.38731-0.38732-0.38732l-0.38731-0.38746h-0.77463l-0.38732-0.38746h-1.5493l-0.77464-0.38746-1.1619 2.3248v0.38747 0.38746l-0.38732 0.77492-0.38732 1.1624-0.38731 0.77492v0.77493l-0.38732 0.38746v0.38746l-0.77463 1.5498h-0.77463-0.38732-0.38731l-2.3239-0.38746h-0.38731l-1.9366 0.77493-1.5493 0.38746v-1.5498h-0.38731v-0.77492-0.38746h-0.38732l-0.38732-0.38746h0.77464v-0.38746-0.38747-0.77492-0.77492h0.38731l0.77463-0.38746-0.77463-0.38746v-0.77492-0.38747h-0.38731v0.38747l-0.38732-0.38747-0.38732-1.1624v-0.38746h0.38732 0.38732v-0.38746h0.38731 0.38732v-0.38746h0.38731 0.38732l-0.38732-0.38746h-0.38731l-0.38732 0.38746h-0.38731l-0.38732-0.38746-0.38732 0.38746v-1.5498h-0.38731-0.38732z"
            )
        ),
        "Noord-Holland" to listOf(
            PathParser().parsePathString("m71.973 49.699-0.77464 0.38746-0.38731 0.38747h-0.38732v0.38746h-0.38731l-0.38732-0.38746v-0.38747-0.38746-0.38746h0.38732 0.38731 0.38732l1.162-0.38746h0.77463v0.38746l-0.77463 0.38746z"),
            PathParser().parsePathString(
                "m73.909 50.474-0.77463 1.1624v0.38746 0.38746 0.77492l-0.38731 1.1624v1.1624 1.5498l-0.77463 2.3248-0.38732 2.3248-0.77463 2.3248v0.77492h-0.38732v0.77492l-0.77463 1.5498v0.77492l-0.77463 2.3248v0.38746 0.38746 0.38746 0.38746 1.1624l-0.38732 1.5498v0.77492 0.77493l-0.38731 1.5498v0.77492 0.38747 0.77492l-0.38732 0.38746v0.38746l-0.38732 2.7122-0.38731 3.4872-0.38732 1.9373-0.38731 0.77492-0.77464 1.5498-0.38731 1.1624 0.77463-0.38746h0.38732l0.77463-0.38747 0.38731 0.38747h-0.38731v0.38746h-0.77463l-0.38732 0.38746h0.77463v0.38746l-0.77463-0.38746h-0.38732v0.38746l-0.77463-0.38746v0.77492l0.38732 0.77492-0.38732 0.38746v0.77493l-0.38731 0.77492-0.38732 1.5498-0.38732 1.1624-0.77463 1.9373-1.5493 3.0997 2.7112 1.1624 1.162 0.38746v-0.77492l0.38731 0.38746 0.38732-0.38746h0.38732 0.38731l0.77463 0.38746-0.38731 0.77492-0.38732 0.38746v0.77492h-0.38731v0.38747 0.38746l-1.162 1.1624v0.38746 0.38746 0.38746 0.77493l-0.38732 0.38746v0.38746h-0.38731v0.38746 0.38746 0.38746h0.38731l0.38732 0.38746h0.38731l0.38732-0.38746 0.77463 0.38746h1.162 0.38732 0.38731l0.38732-0.38746 0.77463-0.38746h0.38732v-0.38746l0.38731 0.38746h0.38732 0.38731l0.77464-0.77492 1.1619 0.38746-0.38731 1.1624 0.77463 0.77493 0.38731-0.77493h0.38732 0.77463l0.38732-0.38746v-0.38746h0.38731 0.38732 0.38732 0.38731 0.38732 0.38731l0.38732-0.38746h0.38732v-0.38746h0.38731l0.38732-0.38746h0.38731v-0.38746l0.77464-0.38746 0.38731-0.38747h0.38732 0.38731l0.38732 0.38747v-0.38747h0.38732 0.38731v-0.38746l0.77463-0.77492-0.38731-0.38746v-0.38746l0.38731-0.38746 0.77463 0.38746h0.38732 0.38732 0.38731v-0.38746l0.77463-0.38746v-0.38747l0.77464 0.38747v-0.38747-0.38746h0.38731v-0.38746h0.38732 0.38731v1.5498l0.38732-0.38746 0.38732 0.38746h0.38731l0.38732-0.38746h0.38731l0.38732 0.38746h-0.38732-0.38731v0.38746h-0.38732-0.38731v0.38746h-0.38732-0.38732v0.38746l0.38732 1.1624 0.38732 0.38747v-0.38747h0.38731v0.38747 0.77492l0.77463 0.38746-0.77463 0.38746h-0.38731v0.77492 0.77492 0.38747 0.38746h-0.77464l0.38732 0.38746h0.38732v0.38746 0.77492h0.38731v1.5498l1.5493-0.38746 1.9366-0.77493h0.38731l2.3239 0.38746h0.38731 0.38732 0.77463l1.162-2.3248v-0.77493l0.38731-0.77492 0.38732-1.1624 0.38732-0.77492v-0.38746-0.38747l1.1619-2.3248 0.77464 0.38746h1.5493l-0.77463-0.77492v-0.38747l0.38731-0.38746h-0.38731-0.38732l-0.38731-0.38746h-0.38732l-0.38732-0.38746h-0.38731v-0.38746l-0.38732-0.38746-0.38731 0.38746h-0.38732-0.38732-1.5493l-0.38732 0.38746h-0.38731l-0.38732 0.38746h-0.38731v-0.38746h-0.38732l-0.77463-0.77492-0.38732-0.77492h-0.38731v-0.38747h-0.77463-0.38732l-0.38732-0.77492h-1.1619-0.38732-0.38732l-0.77463 0.38746-0.38731-0.38746v0.38746h-0.38732v-0.38746h0.38732v-0.38746l-0.38732-0.38746h-0.38732l-0.38731 0.38746h-0.38732-0.38731v-0.38746h0.38731v-0.38746-0.38746l-0.77463-0.38746h-0.38732v0.38746h-0.38731l-0.38732-0.38746h-0.38731v-0.38747h0.38731 0.38732l0.38731-0.38746-1.1619-0.77492v-0.38746l0.77463 0.38746 0.38731 0.38746h0.38732l0.38732-0.38746v0.38746l0.38731 0.38746 0.38732-0.38746v-0.38746-0.38746h0.38731l0.38732-0.38746v-0.77492l0.77463-0.77493 0.38732-0.38746h0.38731 0.38732v-0.38746l0.38732-0.38746v-0.38746l0.77463-0.77492h-0.38732-0.38731l-0.38732-0.38747v0.38747l-0.77463-0.38747v-0.38746-0.38746-0.38746l0.38731-0.38746v-0.38746h-0.38731l-0.38732 0.38746-0.38731-0.38746 0.77463-0.38746h0.77463v-0.38746l-0.38732-0.38747v-0.38746-0.38746l0.38732-0.38746 0.38732 0.38746v-0.38746l0.38731-0.38746 0.38732-0.77492h-0.38732v-0.77493h-0.38731v-0.38746l-0.38732-0.38746v-0.38746l-0.38732-0.77492v-0.38746l-0.77463-1.1624v-0.38746l-0.38731-0.38746v-0.77492l-0.38732-0.77492v-0.38746l-0.38732-0.38747 0.38732-0.38746-0.38732-0.38746v-0.38746-0.38746-0.38746-0.77492-0.38747h0.38732v-0.38746h0.38732l0.38731-0.38746h0.38732 0.38731v0.38746l0.38732 0.38746v-0.38746l0.38732-0.38746h0.38731 0.38732 0.38731l0.77464 0.77492h0.38731l0.38732 0.38747v0.38746h0.77463 0.38732 0.38731l1.162-1.1624h0.38731 0.77464v-0.38746l0.38731-0.38746h0.38732v-0.38746l0.77463-0.38746v-0.38746l0.38732-0.38746v-0.77493-0.38746l0.38731-0.77492h0.38732 0.38731 0.38732l0.38732-0.38746h0.38731l-0.38731-0.38746h0.38731l0.38732-0.38746 0.38731-0.38747-0.77463-0.77492v-0.38746-0.38746-0.38746-0.38746-0.38746-0.38747h-0.38731l-0.38732-0.38746-0.77463-0.38746h-1.162-0.38732l-0.38731-0.38746h-0.77463-0.38732l-0.38732 0.77492-0.38731 0.38746v0.38747l-0.38732-0.38747h-0.38731-0.38732-0.38731l-0.77464-0.77492-0.77463-0.77492 0.38732-0.77492h-0.38732l-0.38731-0.38746h-0.38732l0.77463-5.8119-0.77463-1.1624-1.162-2.3248v-0.38746l-0.38731-0.38747-1.162-2.3248h-0.38732v-0.77493l-0.38731-0.38746h-0.38732l-0.38732 0.38746h-0.38731l-0.38732-0.38746h-0.38731l-0.38732 0.38746h-0.77463l-0.77463 0.77493v0.38746l-0.77464 1.1624h-0.38731l-0.77463 0.38746-0.38732 0.38746-1.5493 0.77493-0.38732-0.38746-1.162-0.77493h-0.38731l-1.162-0.77492-0.38732-0.38746-0.38731-0.38746-0.38732-0.77492v-0.77493-0.77492l0.38732-0.77492v-0.38746h-0.38732v0.38746h-0.38731-0.38732v-0.38746-0.38746h-0.77463-0.77463-0.38732-0.38732zm3.4858 0.38746v-0.38746h-0.38732l0.38732 0.38746zm12.007 2.3248 0.38732 0.38747v-0.77493h-0.38732v0.38746zm-3.4858 47.27v0.38747h0.38731l-0.38731-0.38747zm6.5844-8.5241v0.38746 0.38746l-0.38732 0.77492h0.38732l0.38732-0.38746h0.38731l0.38732-0.38746h0.38731v-0.38746l-0.77463 0.38746-0.77463-0.77492zm10.458 13.561v0.38746h0.38732l-0.38732-0.38746z"
            ),
            PathParser().parsePathString("m80.494 43.887-1.162 1.1624h-0.38732-0.38731-0.38732l-1.162 1.5498v0.38746 0.38747h-0.38731-0.38732l-0.38732-0.38747-0.77463-0.38746h-0.38731l1.1619 1.1624h0.38732-0.77463v0.38746h-0.77463-0.38732 0.38732l-0.38732 0.38746h-0.38732l-0.38731 0.38746h-0.38732v-0.38746-0.77492l-0.38731-1.5498v-0.77492-0.38746l0.38731-1.1624v-0.38746l0.38732-1.1624 0.38731-1.1624 0.38732-1.1624 0.38732-0.38746 0.77463-1.1624 0.77463-1.5498 1.162-1.1624v0.38746 0.38746l0.38731-0.38746 0.77464-0.77492h0.38731v0.38746-0.38746h-0.38731v-0.38746l-0.38732 0.38746-0.77463 0.38746 1.162-2.3248 0.38731-0.38746 0.77463-0.38746v-0.38746h0.38732 0.38732l0.77463 0.77492v0.38746 0.38746h0.38731-0.38731v0.38746l0.77463 0.77493 0.77463 1.1624v0.38746l-0.38731 0.38746v2.3248 1.1624 0.38746l-0.38732 0.77493h-0.38732l-0.38731 0.38746v0.77492l-0.77463 0.77492v0.38746z"),
            PathParser().parsePathString("m95.986 47.762-5.4224 4.6495-0.38732 0.38746h-0.38731v-0.38746h0.77463l5.4224-4.6495z")
        )
    )

    val PathNodeMap: Map<Province, List<List<PathNode>>> =
        PathParserMap.mapValues { entry: Map.Entry<Province, List<PathParser>> ->
            entry.value.map {
                it.toNodes().toList()
            }
        }

    val PathMap: Map<Province, List<Path>> =
        PathParserMap.mapValues { entry: Map.Entry<Province, List<PathParser>> ->
            entry.value.map {
                it.toPath()
            }
        }
}
